# Maintainer: Muflone http://www.muflone.com/contacts/english/
# Contributor: John D Jones III AKA jnbek <jnbek1972 -_AT_- g m a i l -_Dot_- com>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>

pkgname=perl-image-sane
_perl_namespace=Image
_perl_module=Sane
pkgver=5
pkgrel=4
pkgdesc="Perl extension for the SANE (Scanner Access Now Easy) Project"
arch=('loong64' 'x86_64')
url="https://metacpan.org/release/${_perl_namespace}-${_perl_module}"
license=('PerlArtistic' 'GPL')
makedepends=('imagemagick')
depends=('perl' 'sane' 'perl-extutils-depends' 'perl-extutils-pkgconfig' 'perl-readonly' 'perl-test-requires' 'perl-exception-class' 'perl-try-tiny')
provides=('perl-sane')
replaces=('perl-sane')
conflicts=('perl-sane')
source=("https://www.cpan.org/modules/by-module/${_perl_namespace}/${_perl_namespace}-${_perl_module}-${pkgver}.tar.gz")
sha256sums=('229aa0e9f049efa760f3c2f6e61d9d539af43d8f764b50a6e03064b4729a35ff')
options=('!emptydirs')

build() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps
  perl Makefile.PL
  make
}

check() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  export PERL_MM_USE_DEFAULT=1
  make test
}

package() {
  cd "${_perl_namespace}-${_perl_module}-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  make pure_install INSTALLDIRS=vendor DESTDIR="${pkgdir}"
  # Delete unuseful files
  find "${pkgdir}" -name '.packlist' -delete
}
